<?php

/**
 * Paging
 */
class Zend_View_Helper_PaginationAjax extends Zend_View_Helper_Abstract {

    /**
     * Paging Ajax
     * @author TriNT
     * @param <int> $intTotalRecord
     * @param <int> $intPage
     * @param <String> $strLink
     * @param <array> $arrParam
     * @return string
     */
    public function PaginationAjax($intTotalRecord, $intPage, $strLink, $cateid,$perpage=20)
    {
        $strReturn = '<div class="txt_paging_video">';
        if( $intPage >1 ){
            //link preview page
            $strtPreviousAction = ($intPage > 1) ? 'onclick="return '.$strLink.'('.($intPage - 1).',' .$cateid. ');"': 'onclick="return false"';
            $strReturn .= '<a href="javascript:void(0)" '.$strtPreviousAction.'  class="txt_green" title="Trang trước">Quay lại</a>&nbsp; | &nbsp; ';
        }
        // content current page/ total page
        $strReturn .= '<span class="txt_gray">Trang '. $intPage . '</span>';
        //link next page
        if( $intTotalRecord >= $perpage ){ 
            $strtNextAction = ($intTotalRecord >= $perpage) ? 'onclick="return '.$strLink.'('.($intPage + 1).',' .$cateid. ');"' : 'onclick="return false"';
            $strReturn .= '<a href="javascript:void(0)" '.$strtNextAction.' class="txt_green" title="Trang kế"> &nbsp; | &nbsp;  Xem tiếp</a> ';
        }

        $strReturn .= ' </div>';

        return $strReturn;
    }
}